Azure Virtual Machines (VMs)
Azure VM Architecture:
- Virtual Machine (VM):
- Represents a computer system within the Azure cloud.
- Runs an operating system (Windows or Linux) and applications.
- Virtual Hard Disk (VHD):
- The storage for the VM, containing the operating system, applications, and data.
- Stored in Azure Storage, providing durability and accessibility.
- Azure Storage:
- VMs use Azure Storage to store VHDs, providing scalability and redundancy.
- Azure Networking:
- VMs are part of a virtual network, enabling communication with other Azure resources and on-premises
networks.
- Azure Load Balancer can distribute incoming network traffic across multiple VM instances.
- Availability Sets:
- Organizes VMs to provide high availability.
- Distributes VMs across multiple physical servers to minimize the impact of hardware failures.
- Scale Sets:
- Enables automatic scaling of VM instances based on demand.
- Managed Disks:
- Simplifies disk management by handling the storage accounts associated with VM disks.
Azure VM Configuration Examples:
1. Creating a VM in the Azure Portal:
- Go to the Azure Portal.
- Click on "Create a resource" > "Compute" > "Virtual machine."
- Configure settings like subscription, resource group, region, VM name, OS, etc.
- Choose a size based on your resource requirements.
- Configure networking settings, including virtual network and subnet.
- Set up storage options, either using managed disks or unmanaged disks.
- Review and create the VM.
2. Creating a VM using Azure CLI:
az group create --name MyResourceGroup --location eastus
az vm create \
--resource-group MyResourceGroup \
--name MyVM \
--image UbuntuLTS \
--admin-username azureuser \
--admin-password Password123! \
--size Standard_DS1_v2
3. Configuring Network Security Groups (NSG):
- Define inbound and outbound rules to control traffic to and from the VM.
- Example using Azure CLI:
az network nsg create --resource-group MyResourceGroup --name MyNSG
az network nsg rule create \
--resource-group MyResourceGroup \
--nsg-name MyNSG \
--name AllowSSH \
--priority 100 \
--protocol tcp \
--destination-port-range 22 \
--access allow
4. Scaling VMs with Azure Virtual Machine Scale Sets:
az vmss create \
--resource-group MyResourceGroup \
--name MyScaleSet \
--image UbuntuLTS \
--upgrade-policy-mode automatic \
--admin-username azureuser \
--admin-password Password123! \
--instance-count 3
az vmss update \
--resource-group MyResourceGroup \
--name MyScaleSet \
--set virtualMachineProfile.scaleInPolicy.deploymentMinimumInstanceCount=1 \
--set virtualMachineProfile.scaleInPolicy.deploymentMaximumInstanceCount=5